package com.bloveoacom.weichi.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import com.bloveoacom.base.BaseFragment;
import com.bloveoacom.base.BaseListFragment;
import com.bloveoacom.util.ActivityUtil;
import com.bloveoacom.weichi.R;
import com.bloveoacom.weichi.activity.ReleasePostActivity;
import com.bloveoacom.weichi.activity.SearchActivity;
import com.bloveoacom.weichi.adapter.AllFragmentPagerAdapter;
import com.bloveoacom.weichi.adapter.MyPostAdapter;
import com.bloveoacom.weichi.bean.NewsPostBean;
import com.bloveoacom.weichi.bean.PostCoinBean;
import com.bloveoacom.weichi.contract.PostListContract;
import com.bloveoacom.weichi.model.PostListModel;
import com.bloveoacom.weichi.presenter.PostListPresenter;
import com.bloveoacom.weight.LlkjToolBar;
import com.bloveoacom.weight.NoScrollViewPager;
import com.flyco.tablayout.SlidingTabLayout;
import com.gyf.barlibrary.ImmersionBar;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * author: zhu.px
 * e-mail: 1271901673@qq.com
 * time  : 2018/5/8
 * desc  : 我的
 */
public class PostParentFragment extends BaseFragment {

    @BindView(R.id.title_bar)
    LlkjToolBar titleBar;
    @BindView(R.id.segment_tab2)
    SlidingTabLayout segmentTab;
    @BindView(R.id.fl_content2)
    NoScrollViewPager fl_content2;
    private final String[] mTitles = {"默认", "热度","奖池"};
    public static PostParentFragment newInstance() {
        Bundle args = new Bundle();
        PostParentFragment fragment = new PostParentFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getLayoutResId() {
        return R.layout.fragment_tablayout2;
    }



    @Override
    public void initView() {
        titleBar.setToolBar("微池",
                false, "", R.drawable.ic_back, true, "", R.drawable.ic_search);
    }

    @Override
    protected View getViewSetTB() {
        return titleBar;
    }

    @Override
    public void initData() {
        List<BaseFragment> list = new ArrayList<>();
        list.add(PostListFragment.newInstance(0));
        list.add(PostListFragment.newInstance(1));
        list.add(PostListFragment.newInstance(2));
        fl_content2.setOffscreenPageLimit(3);
        fl_content2.setAdapter(new AllFragmentPagerAdapter(getChildFragmentManager(), list, Arrays.asList(mTitles)));
        segmentTab.setViewPager(fl_content2);
    }

    @Override
    public void getBundleExtras(Bundle extras) {

    }

    @Override
    public void initListener() {
        titleBar.setRightButtonOnClickLinster(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivityUtil.startActivity(mContext, SearchActivity.class,"2");
            }
        });
    }
    @OnClick({R.id.iv_release})
    public void onClick(View view){
        switch (view.getId()) {
            case R.id.iv_release:
                ActivityUtil.startActivity(mContext, ReleasePostActivity.class);
                break;
        }
    }

}
